package reflection;

public class Test03 {
    public static void main(String[] args) throws ClassNotFoundException {
        // 1、类.class
        Class<Person> personClass = Person.class;
        System.out.println(personClass);

        // 2、实例.getClass()
        Student student = new Student();
        Class studentClass = student.getClass();
        System.out.println(studentClass);

        // 3、Class.forName("...")
        Class<?> teacherClass = Class.forName("reflection.Teacher");
        System.out.println(teacherClass);

        // 内置类型.Type
        Class<Integer> integerClass = Integer.TYPE;
        System.out.println(integerClass);

        // 获得父类类型
        Class studentClassSuperclass = studentClass.getSuperclass();
        System.out.println(studentClassSuperclass);

    }
}

class Person {
    protected String name;
}

class Student extends Person{
    public Student() {
        this.name = "学生";
    }
}

class Teacher extends Person{
    public Teacher() {
        this.name = "老师";
    }
}

